package com.pxml2pdf;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.dom4j.DocumentException;

public class TEST {
	public static void main(String[] args) throws IOException, DocumentException {
		String html = readFile("E:/var/govhrms/temp/report/test.xml");//test (1).pdf
		//html = readFile("E:/workspace/pxml2pdf/test/testxxxxxxxx.pdf");
		String tmpFile = "E:/mickyok.pdf";
		//System.out.print(html);
		Pxml2pdf pxml = new Pxml2pdf(html, tmpFile,"");
		pxml.Convert();
		System.out.print("OK");

	}

	public static String readFile(String filePath) throws IOException {
		StringBuffer sb = new StringBuffer();
		readToBuffer(sb, filePath);
		return sb.toString();
	}

	public static void readToBuffer(StringBuffer buffer, String filePath) throws IOException {
		InputStream is = new FileInputStream(filePath);
		String line;
		BufferedReader reader = new BufferedReader(new InputStreamReader(is));
		line = reader.readLine();
		while (line != null) {
			buffer.append(line);
			buffer.append("\n");
			line = reader.readLine();
		}
		reader.close();
		is.close();
	}

}
